package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Officialstu;
import cn.wolfcode.crm.mapper.OfficialstuMapper;
import cn.wolfcode.crm.query.QueryForObject;
import cn.wolfcode.crm.query.ReportQueryForObject;
import cn.wolfcode.crm.service.IOfficialstuService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class OfficialstuService implements IOfficialstuService {
    @Autowired
    private OfficialstuMapper mapper;

    public void insert(Officialstu record) {
        mapper.insert(record);

    }

    public Officialstu selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    public List<Officialstu> selectAll() {
        return mapper.selectAll();
    }

    public void updateByPrimaryKey(Officialstu record) {
        mapper.updateByPrimaryKey(record);
    }

    public PageResult query(QueryForObject qo) {
        int total = mapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }
        List<Officialstu> rows = mapper.queryForList(qo);

        return new PageResult(total, rows);
    }

    @Override
    public List<Officialstu> selectNoPayAll() {
        return mapper.selectNoPayAll();
    }

    @Override
    public Officialstu queryById(Long id) {
        return mapper.queryById(id);
    }

    //改变学员状态，1在读 2转班中 3休学 4劝退
    @Override
    public void changeState(Long stuId, Integer state) {
        mapper.changeState(stuId, state);
    }

    @Override
    public void changeClasses(Long stuId, Long newGradeId, Integer state) {
        mapper.changeClasses(stuId, newGradeId, state);
    }

    @Override
    public int selectAllStudentByBigClient(Long id) {
        return mapper.selectAllStudentByBigClient(id);
    }


    @Override
    public List<Officialstu> selectAllByRefundState() {
        return mapper.selectAllByRefundState();
    }

    @Override
    public List<Map<String, Object>> selectGroupBy(ReportQueryForObject groupName) {
        return mapper.selectGroupBy(groupName);
    }
}
